/**
* 作者: lichuan
* 日期: 2025-07-07 15:23:01
* 备注: 用户每日补给活动表
*/
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.base.AllParam;
import com.motu.vertx.module.utility.toolset.TimeUtils;
import io.vertx.core.json.JsonObject;

public class UserActDailySupply extends UserActDailySupplyModel {
	public UserActDailySupply() {
		super();
	}

	public JsonObject insert() {
		putResetTime(TimeUtils.getCurTime());// 因为初始是0，只更新次字段就行
		return super.insert();
	}

	public void reset() {
		// 每日重置
		long curTime = TimeUtils.getCurTime();
		long startTimeOfDay = TimeUtils.getStartTimeOfDay(getResetTime());
		long refreshTime = startTimeOfDay + (long) TimeUtils.HOUR * AllParam.DAILY_SUPPLY_REFRESH_TIME;
		// 当前时间大于刷新时间 并且今日没有刷新过
		if (curTime >= refreshTime  && !TimeUtils.isToday(getResetTime())) {
			putResetTime(TimeUtils.getCurTime());
			putReceiveList("");
			update();
		}
	}
}
